package com.example.artemis.events;

/**
 * 消息发送成功事件
 * 当消息成功发送到队列时触发此事件
 */
public class MessageSentEvent extends MessageEvent {

    private final String producerId;
    private final long productionTime;
    private final int messageSize;

    public MessageSentEvent(String messageId, String queueName, String producerId,
                          long productionTime, int messageSize) {
        super(messageId, queueName);
        this.producerId = producerId;
        this.productionTime = productionTime;
        this.messageSize = messageSize;
    }

    /**
     * 获取生产者ID
     */
    public String getProducerId() {
        return producerId;
    }

    /**
     * 获取消息生产耗时（毫秒）
     */
    public long getProductionTime() {
        return productionTime;
    }

    /**
     * 获取消息大小（字节）
     */
    public int getMessageSize() {
        return messageSize;
    }

    @Override
    public String getEventType() {
        return "MESSAGE_SENT";
    }

    @Override
    public String toString() {
        return String.format("MessageSentEvent{messageId='%s', queueName='%s', producerId='%s', " +
                "productionTime=%dms, messageSize=%d bytes, timestamp=%d}",
                getMessageId(), getQueueName(), producerId, productionTime, messageSize, getTimestamp());
    }
}